/*
-------------------------------------------------------------------
BIE is Copyright 2001-2003 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
*/
package com.webdeninteractive.sbie.config;

import java.util.Collection;
import java.util.Map;

import  com.webdeninteractive.sbie.config.data.ConfigData;
import  com.webdeninteractive.sbie.config.data.ClientData;
import  com.webdeninteractive.sbie.config.data.ServiceData;

/**
 * Interface providing access to configuration information for 
 * SBIE components.
 *
 * @author gfast
 * @version $Id: SystemConfig.java,v 1.1.1.1 2003/05/20 16:56:49 gdf Exp $ 
 */
public interface SystemConfig extends BootConfig {

    /** 
     *  Get the list of clients which the system should start
     *  when <code>RemoteSystem.start</code> is called.
     * @return Array of client names.
     */
    public String[] getStartupClientNames();

    /**
     *  Get a complete list of all the classes required for components
     *  in this system (ie, implementations of Client, Service,
     *  RemoteSystem, etc).  These can be checked against the
     *  RemoteSystem's classloader to determine if upgrades are needed
     *  for this configuration.
     * @return Array of class names 
     *         (some of which may not be currently loadable).
     */
    public String[] getRequiredClassNames();

    /**
     *  Get the list of all configured clients.  The list returned by
     *  this method will be a superset of that returned by
     *  {@link #getStartupClientNames}.
     * @return Array of client names.
     */
    public String[] getClientNames();


    /**
     *  Get the class name of the class which is configured to implement
     *  the client with the given name.
     * @return A class name.
     */
    public String getClientImplClass( String clientName );

    /** @return a Collection of {@link ClientData} objects. */        
    public Collection getClientData();

    /**
     * Get the names Services configured for a given Client.
     *
     * @param clientName Name of the Client to check.
     * @return Array of Service names.
     */
    public String[] getServicesForClient( String clientName );

    /**
     * Get the class name implementing a given Service.
     * @param clientName Name of the Client owning the named Service.
     * @param serviceName Name of the Service to check.
     * @return A class name.
     */
    public String getServiceImplClass( String clientName, String serviceName );

    /**
     * Get the name of the ProtocolHandler associated with the given Client.
     * @return Name of a ProtocolHandler.
     */
    public String getProtocolHandlerName( String clientName );

    /** Get the class name implementing a given Client's ProtocolHandler.
     * @return A class name.
     */
    public String getProtocolHandlerClassName( String clientName );

    /** @return a Collection of {@link ServiceData} objects. */
    public Collection getServiceData( String clientName );

    /** @return a ServiceData object representing the configuration of the
     *          service of the given name and client. */
    public ServiceData getServiceDataByName( String clientName, 
                                             String serviceName );

    /** @return a ClientData object representing the configuration of
     *          the client of the given name. */
    public ClientData getClientDataByName( String clientName );

    /** Get configuration data object wrapped by this interface. 
     *  For use if the ConfigData needs to be modified directly.
     *  Modification of configuration data should be done through the 
     *  <code>SystemConfig</code> interface, if possible.
     */
    public ConfigData getConfigDataRoot();

    /** Get a set of parameters configured for a given Service.
     * @param clientName Name of the Client owning the given Service.
     * @param serviceName Name of the Service.
     * @return A Map of name->(String)value pairs.
     */
    public Map getServiceParameters( String clientName, String serviceName );


    // --- set/edit methods: use data.* beans

    /** Sets a ServiceData configuration for the given named client.
     *  If a service matching the name of the given ServiceData
     *  is already configured for this clientName, it will be replaced
     *  with the given ServiceData.
     */
    public void setServiceData( String clientName, 
                                ServiceData editedServiceData );

    public void setClientData( ClientData editedClientData );

    /** Returns a representation of this configuration, in the file format
     *  recognized by the implementing class (@see{#setLocation}).
     *  The configuration data is returned as a (possibly large) String.
     */
    public String toFileFormat();
}
